<?php
class StudentModel extends Model
{
	 protected $_validate = array(
        array('studentid','require','学号不能为空！'),
        array('studentid','','该学号已经存在！',0,'unique',1),
        array('name', 'require', '姓名不能为空！'),
        array('password', 'require', '密码不能为空！'),
    );
	
	public function addStudent($name, $password)
	{
		$student['name'] = $name;
		$student['password'] = $password;
		return $this->add($student);
    }
	
	public function getById($id)
	{
		$condition['id'] = $id;
		$student = $this->where($condition)->find();
		return $student;
    }
	
    public function hasStudent($name)
	{
		$condition['name'] = $name;
		$result = $this->where($condition)->find();
		if($result != null)
		return FALSE;
		else return TRUE;
	}
	
	
	
}

?>